﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using MediaServer.VideoCore;

namespace MediaServer
{
    class CameraModel : INotifyPropertyChanged
    {
        public static CameraModel Create(IPCamera camera)
        {
            return new CameraModel
            {
                ID = camera.ID,
                IPAddress = camera.IPAddress,
                Name = camera.Name,
                UserName = camera.UserName,
                Password = camera.Password,
                OnOff = camera.OnOff,
                Available = camera.Available
            };
        }
        public Guid ID { get; set; }
        public string Name { get; set; }
        public string IPAddress { get; set; }
        public string UserName { get; set; }
        public string Password { get; set; }
        public bool m_onOff;
        public bool m_check;
        public bool m_available;
        public event PropertyChangedEventHandler PropertyChanged;
        public void InitCamera(string name, string ip, string user, string pass, bool on, bool available)
        {
            this.Name = name;
            this.IPAddress = ip;
            this.UserName = user;
            this.Password = pass;
            this.m_onOff = on;
            this.m_available = available;
        }
        public bool OnOff
        {
            get { return m_onOff; }
            set
            {
                if (m_onOff != value)
                {
                    m_onOff = value;
                    OnPropertyChanged("OnOff");
                }
            }
        }
        public bool Available
        {
            get { return m_available; }
            set
            {
                if (m_available != value)
                {
                    m_available = value;
                    OnPropertyChanged("Available");
                }
            }
        }
        protected void OnPropertyChanged(string name)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(name));
            }
        }
        //public List<NameValuePair> Parameters { get; set; } //used to return firmware/model num and any other info
    }
}
